<template>
    <div>

        <!-- 顶部滑动条 -->
        <div id="slider" class="mui-slider">
            <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
                <div class="mui-scroll">
                    <a :class="['mui-control-item',item.id == 1 ? 'mui-active' : '']" @tap="getcatesById(item.id)" v-for="item in cates" :key="item.id">
                        {{ item.name }}
                    </a> 
                </div>
            </div>
        </div>

        <ul class="photo-list">
            <router-link tag='li' v-for="item in list" :key="item.id" :to="'/home/photoinfo/'+item.id">
                <img v-lazy="item.img_url">
                <div class="info">
                    <h1 class="info-title">
                        {{item.title}}
                    </h1>
                    <div class="info-body">
                        {{item.zhaiyao}}
                    </div>
                </div>
            </router-link>
        </ul>
    </div>
</template>

<script>
 

import mui from '../../lib/mui/js/mui.min.js'
//import func from './vue-temp/vue-editor-bridge.js';



export default {
    data(){
        return {
            cates:[],
            list:[]
        }
    },
    created(){
        this.getcates(),
        this.getlist()
    },
    mounted(){
        //当 组件中的DOM结构被渲染好并放到页面
        mui('.mui-scroll-wrapper').scroll({
            deceleration:0.0005    
        });
    },
    methods:{
        getcates(){
            this.cates = [
                {id:1,name:'全部'},{id:2,name:'家居生活'},
                {id:3,name:'摄影设计'},{id:4,name:'明星美女'},
                {id:5,name:'空间设计'},{id:6,name:'户型装饰'},
                {id:7,name:'广告设计'}
            ];
        },
        getcatesById(id){
            var data = this.getData();
            this.list = [];
            if(id == 1)
            {
                this.list = this.getData();
            }else{
                for(var i=0; i<data.length; i++)
                {
                    if(data[i].cateid == id) 
                    {
                            this.list.push(data[i]);
                    } 
                } 
            }
        },
         getlist(){
            this.list = this.getData();
        },
        getData(){
            return [
                {id:1,cateid:5,title:'全部',img_url:'../../images/001.jpg',zhaiyao:'家居生活'},
                {id:2,cateid:5,title:'家居生活',img_url:'../../images/001.jpg',zhaiyao:'家居生活'},
                {id:3,cateid:5,title:'摄影设计',img_url:'../../images/001.jpg',zhaiyao:'家居生活'},
                {id:4,cateid:5,title:'明星美女',img_url:'../../images/001.jpg',zhaiyao:'家居生活'},
                {id:5,cateid:5,title:'空间设计',img_url:'../../images/001.jpg',zhaiyao:'家居生活'},
                {id:6,cateid:6,title:'户型装饰',img_url:'../../images/001.jpg',zhaiyao:'家居生活'},
                {id:7,cateid:7,title:'广告设计',img_url:'../../images/001.jpg',zhaiyao:'家居生活'}
            ];
        }
    }
}
</script>

<style lang="scss" scoped>

* {
    touch-action: pan-y;
}
.photo-list{ 
    list-style: none;
    margin: 0;
    padding: 10px;
    padding-bottom: 0;
    li{
        background-color: #ccc;
        text-align: center;
        margin-bottom: 10px;
        box-shadow: 0 0 9px #999;
        position: relative;
        img{
            width: 100%;
            vertical-align: middle;
        }
        img[lazy='loading']{
            width: 40px;
            height: 300px;
            margin: auto;
        }
        .info{
            color: #fff;
            text-align: left;
            position:absolute;
            bottom:0;
            background-color: rgba(0,0,0,0.4);
            max-height: 84px;
            width: 100%;
            padding: 3px;
            .info-title{
                font-size: 14px;
            }

            .info-body{
                font-size: 12px;
            }
        }
    }
   
}

</style>
